<{include file="header.htm"}>
<style>
    .input_group_input {
        background: none;
        width: 100%;
        padding: 0.8em 10px 0.8em 0.8em;
        box-sizing: border-box;
        height: 45px;
        font-size: 14px;
        color: #333;
        text-align: left;
    }
    input[type='password'] {
        border: none;
        outline: none;
    }
</style>
<body>
<header>
    <div class="header_top">
        <div class="st_back"><a href="javascript:window.history.back();"></a></div>
        <h1 class="tit">找回密码</h1>
        <a class="top_user_reg" href="<{$config.weburl}>/login.php">登录</a>
    </div>
</header>
 <div class="mid_content">
        <div class="st_user_box">
            <{if $action == 'get_mobile'}>

                <form action="lostmobile.php" method="get" onsubmit=" return check_data();">
                    <input name="action" type="hidden" value="get_mobile" />
                <div class="login_page clearfix number_password">
                    <p><strong>手机号：</strong><input type="text" class="username" value="" name="mobile" id="mobile" placeholder="请输入手机号" /></p>
                    <p><strong>验证码：</strong></strong><input type="text" class="yzm_txt focus" id="code" name="code"  value="" placeholder="验证码"   />
                        <span><img src="<{$config.weburl}>/includes/rand_func.php?rand=<{$now_time}>" style="cursor:pointer;margin-top: 6px;margin-left: 2px" onClick="this.src=this.src+'?rand='+Math.random()" title="点击我更换图片" alt="点击我更换图片"></span>
                    </p>

                </div>
                <p  class="submit_btn"><input class="login_in" name="" type="submit" value="下一步"></p>
            </form>

            <{/if}>

            <{if $action == 'mobile_pass'}>

            <form action="lostmobile.php" method="post" onsubmit=" return check_up_mobile();">
                <input name="lostpass" type="hidden" value="lostpass" />
                <div class="login_page clearfix number_password">
                    <p><strong>手机号：</strong><input type="text" class="username" value="<{$smarty.get.mobile}>" name="mobile" id="mobile" placeholder="请输入手机号" /></p>
                    <p><strong>验证码：</strong></strong><input type="text" class="yzm_txt focus" id="sms_code" name="sms_code"  value="" placeholder="验证码"   />
                        <span id="sendCode" style=" text-align: center; background:#e77817; color: #fff; height: 48px; padding: 10px 5px; line-height: 48px;">点击发送</span>
                    </p>
                    <p><strong>密码：</strong><input type="password" value="" name="password" id="password" placeholder="请输入新密码" /></p>
                </div>
                <p  class="submit_btn"><input class="login_in" name="" type="submit" value="下一步"></p>
            </form>


            <{/if}>


</div>
</div>

<script type="application/javascript">
    function check_data(){
        var mobile = $("#mobile").val();
        var code   = $("#code").val();
        var preg_mobile = /^1\d{10}$/;
        if(mobile == ''){
            alert('手机号不能为空');
            return false;
        } else if(!preg_mobile.test(mobile)){
            alert("请填写正确的手机号");
            return false;
        } else {
            return true;
        }

    }

    $(function() {
        //发送短信
        $("#sendCode").on("click",function(){
            var mobile = $("#mobile").val();
            var mobile_part = /^1\d{10}$/;
            if(mobile == ''){
                alert("请填写手机号");
                return false;
            } else if(!mobile_part.test(mobile)){
                alert("请填写正确的手机号");
                return false;
            } else {
                if($(this).hasClass("on")){
                    return false;
                }
                $.post("ajax_back_end.php",{action:'sendSms',mobile:mobile},function(ret){
                    ret = eval('('+ret+')');
                    if(!ret.status){
                        alert(ret.msg);
                    } else {
                        settime(60);
                    }

                });


            }
        });

        var countdown = 60;
        function settime(val) {
            if (countdown == 0) {
                $("#sendCode").removeClass("on");
                $("#sendCode").html("点击发送");
                return false;
            } else {
                $("#sendCode").html("重新发送" + countdown + 's');
                countdown--;
                $("#sendCode").addClass("on");
            }
            setTimeout(function() {
                settime(val)
            },1000)
        }

    });

    function check_up_mobile(){
        var mobile = $("#mobile").val();
        var sms_code   = $("#sms_code").val();
        var preg_mobile = /^1\d{10}$/;
        var password = $("#password").val();
        if(mobile == ''){
            alert('手机号不能为空');
            return false;
        } else if(!preg_mobile.test(mobile)){
            alert("请填写正确的手机号");
            return false;
        } else if(sms_code == ''){
            alert('验证码不能为空');
            return false;
        } else if(password == ''){
            alert('密码不能为空');
            return false;
        } else if(password.length < 6 ){
            alert('密码长度不能小于6位');
            return false;
        } else {
            return true;
        }
    }


</script>

<{include file="footer.htm"}>
